{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    " # 首先 import 必要的模块\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "from sklearn.model_selection import GridSearchCV\n",
    "from sklearn.svm import LinearSVC\n",
    "from sklearn.svm import SVC\n",
    "\n",
    "from matplotlib import pyplot\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>pregnants</th>\n",
       "      <th>Plasma_glucose_concentration</th>\n",
       "      <th>blood_pressure</th>\n",
       "      <th>Triceps_skin_fold_thickness</th>\n",
       "      <th>serum_insulin</th>\n",
       "      <th>BMI</th>\n",
       "      <th>Diabetes_pedigree_function</th>\n",
       "      <th>Age</th>\n",
       "      <th>BMI_missing</th>\n",
       "      <th>Target</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>763.000000</td>\n",
       "      <td>763.000000</td>\n",
       "      <td>763.000000</td>\n",
       "      <td>763.000000</td>\n",
       "      <td>763.000000</td>\n",
       "      <td>763.000000</td>\n",
       "      <td>763.000000</td>\n",
       "      <td>763.000000</td>\n",
       "      <td>763.000000</td>\n",
       "      <td>763.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>0.226582</td>\n",
       "      <td>0.501205</td>\n",
       "      <td>0.494062</td>\n",
       "      <td>0.249972</td>\n",
       "      <td>0.170535</td>\n",
       "      <td>0.476703</td>\n",
       "      <td>0.168436</td>\n",
       "      <td>0.204522</td>\n",
       "      <td>0.985583</td>\n",
       "      <td>0.348624</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>0.198513</td>\n",
       "      <td>0.197004</td>\n",
       "      <td>0.123456</td>\n",
       "      <td>0.096628</td>\n",
       "      <td>0.102361</td>\n",
       "      <td>0.117634</td>\n",
       "      <td>0.141744</td>\n",
       "      <td>0.196203</td>\n",
       "      <td>0.119279</td>\n",
       "      <td>0.476847</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>0.058824</td>\n",
       "      <td>0.354839</td>\n",
       "      <td>0.408163</td>\n",
       "      <td>0.195652</td>\n",
       "      <td>0.128606</td>\n",
       "      <td>0.406855</td>\n",
       "      <td>0.070666</td>\n",
       "      <td>0.050000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>0.176471</td>\n",
       "      <td>0.470968</td>\n",
       "      <td>0.489796</td>\n",
       "      <td>0.271739</td>\n",
       "      <td>0.170535</td>\n",
       "      <td>0.476900</td>\n",
       "      <td>0.126388</td>\n",
       "      <td>0.133333</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>0.352941</td>\n",
       "      <td>0.625806</td>\n",
       "      <td>0.571429</td>\n",
       "      <td>0.271739</td>\n",
       "      <td>0.170535</td>\n",
       "      <td>0.544709</td>\n",
       "      <td>0.234202</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        pregnants  Plasma_glucose_concentration  blood_pressure  \\\n",
       "count  763.000000                    763.000000      763.000000   \n",
       "mean     0.226582                      0.501205        0.494062   \n",
       "std      0.198513                      0.197004        0.123456   \n",
       "min      0.000000                      0.000000        0.000000   \n",
       "25%      0.058824                      0.354839        0.408163   \n",
       "50%      0.176471                      0.470968        0.489796   \n",
       "75%      0.352941                      0.625806        0.571429   \n",
       "max      1.000000                      1.000000        1.000000   \n",
       "\n",
       "       Triceps_skin_fold_thickness  serum_insulin         BMI  \\\n",
       "count                   763.000000     763.000000  763.000000   \n",
       "mean                      0.249972       0.170535    0.476703   \n",
       "std                       0.096628       0.102361    0.117634   \n",
       "min                       0.000000       0.000000    0.000000   \n",
       "25%                       0.195652       0.128606    0.406855   \n",
       "50%                       0.271739       0.170535    0.476900   \n",
       "75%                       0.271739       0.170535    0.544709   \n",
       "max                       1.000000       1.000000    1.000000   \n",
       "\n",
       "       Diabetes_pedigree_function         Age  BMI_missing      Target  \n",
       "count                  763.000000  763.000000   763.000000  763.000000  \n",
       "mean                     0.168436    0.204522     0.985583    0.348624  \n",
       "std                      0.141744    0.196203     0.119279    0.476847  \n",
       "min                      0.000000    0.000000     0.000000    0.000000  \n",
       "25%                      0.070666    0.050000     1.000000    0.000000  \n",
       "50%                      0.126388    0.133333     1.000000    0.000000  \n",
       "75%                      0.234202    0.333333     1.000000    1.000000  \n",
       "max                      1.000000    1.000000     1.000000    1.000000  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#input data\n",
    "train = pd.read_csv(\"FE_pima-indians-diabetes.csv\")\n",
    "train.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pregnants                       False\n",
       "Plasma_glucose_concentration    False\n",
       "blood_pressure                  False\n",
       "Triceps_skin_fold_thickness     False\n",
       "serum_insulin                   False\n",
       "BMI                             False\n",
       "Diabetes_pedigree_function      False\n",
       "Age                             False\n",
       "BMI_missing                     False\n",
       "Target                          False\n",
       "dtype: bool"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.isnan(train).any()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "#  get labels\n",
    "y_train = train['Target']   \n",
    "X_train = train.drop([\"Target\"], axis=1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1.LinearSVC训练模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "LinearSVC-最佳度量值: 0.7693315858453473\n",
      "LinearSVC-最佳参数： {'C': 0.1, 'penalty': 'l2'}\n"
     ]
    }
   ],
   "source": [
    "#线性SVC\n",
    "Cs = [0.001, 0.01, 0.1, 1, 10, 100, 1000]\n",
    "penaltys=['l1','l2']\n",
    "param_grid = {'C': Cs,'penalty': penaltys}\n",
    "grid = GridSearchCV(LinearSVC(dual=False), param_grid, cv=5, n_jobs = 4)\n",
    "\n",
    "grid.fit(X_train, y_train)\n",
    "\n",
    "print('LinearSVC-最佳度量值:',grid.best_score_)  # 获取最佳度量值\n",
    "print('LinearSVC-最佳参数：',grid.best_params_)  # 获取最佳度量值时的代定参数的值。是一个字典"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEWCAYAAACXGLsWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3Xl8VvWZ///XlRAIewIEkB0RFFBcQBTXuiFTba2tVaxrp9U6rX477bT9OtP5qbVfO0tn6syonaqt41IrOm7FFhuo2roAylJQ76AICBIkIUAAw5bt+v1xTvAmhNx3kvvkXvJ+Ph73w/uc8znnvo4k95XP55zPuczdERERaU1eugMQEZHMp2QhIiIJKVmIiEhCShYiIpKQkoWIiCSkZCEiIgkpWUiXZ2Znmtn76Y5DJJMpWUiXYmbrzez8+HXu/pq7H52meLqb2b+bWbmZ1YTx/Ue47Q9mdmcL+1xiZhVm1i1cnm5m88xsh5ltN7O3zOyrnX0uktuULETSJPyy/3tgGjAd6At8BlgeNnkEuNrMrNmu1wCPu3u9mc0AXgb+DBwFDAT+BviryE9AuhQlC+nyzOwzZlYet7zezL5nZm+b2U4ze9LMCuO2X2xmK8K/5Bea2ZS4bbea2Voz+8TMyszs0rht15vZG2Z2t5ltA+4ATgaec/ePPbDe3R8Nd3me4Mv/zLhjFAMXA01tfgo84u7/4u5bw2Msc/fLU/4/Sro0JQuRll0OzALGAlOA6wHM7ETgIeAbBF/k9wNzzaxHuN9agi/3/sCPgF+b2RFxxz0FWAcMAe4CFgPfNbNvmtlx8b0Id98LPAVc2yyu99x9pZn1AmYAT6fwvEVapGQh0rL/Cv/a3w68AJwQrr8RuN/d33T3Bnd/BNgPnArg7v8b7tfo7k8CHx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Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# plot CV误差曲线\n",
    "test_means = grid.cv_results_[ 'mean_test_score' ]\n",
    "test_stds = grid.cv_results_[ 'std_test_score' ]\n",
    "\n",
    "test_scores =  np.array(test_means).reshape(len(Cs),len(penaltys))\n",
    "test_stds = np.array(test_stds).reshape(len(Cs),len(penaltys))\n",
    "\n",
    "x_axis = np.log10(Cs)\n",
    "for i, value in enumerate(penaltys):\n",
    "    pyplot.errorbar(x_axis, test_scores[:,i], yerr=test_stds[:,i] ,label = penaltys[i] )\n",
    "    \n",
    "pyplot.legend(loc='best')\n",
    "pyplot.xlabel( 'log(C)' )                                                                                                      \n",
    "pyplot.ylabel( 'accuary' )\n",
    "pyplot.title('LinearSVC')\n",
    "\n",
    "pyplot.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "LinearSVC-最佳度量值: 0.7693315858453473\n",
      "LinearSVC-最佳参数： {'C': 0.1}\n"
     ]
    }
   ],
   "source": [
    "#C在0.1附近最优，缩小搜索范围试试\n",
    "c=10**0.25\n",
    "\n",
    "Cs = [0.01, 0.01*(10**0.5), 0.1, 0.1*c, 0.1*c*c, 0.1*c*c*c, 1]\n",
    "\n",
    "grid = GridSearchCV(LinearSVC(penalty='l2',dual=False), param_grid = {'C': Cs}, cv=5, n_jobs = 4)\n",
    "\n",
    "grid.fit(X_train, y_train)\n",
    "\n",
    "LinearSVC_best_score=grid.best_score_ # 获取最佳度量值\n",
    "print('LinearSVC-最佳度量值:',LinearSVC_best_score)\n",
    "print('LinearSVC-最佳参数：',grid.best_params_)  # 获取最佳度量值时的代定参数的值。是一个字典"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2..SVC训练模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SVC-最佳度量值: 0.7745740498034076\n",
      "SVC-最佳参数： {'C': 1, 'kernel': 'rbf'}\n"
     ]
    }
   ],
   "source": [
    "#线性SVM\n",
    "Cs = [0.001, 0.01, 0.1, 1, 10, 100, 1000]\n",
    "kernels=['linear','poly','rbf','sigmoid']\n",
    "param_grid = {'C': Cs,'kernel': kernels}\n",
    "grid = GridSearchCV(SVC(gamma='auto',decision_function_shape='ovo'), param_grid, cv=5, n_jobs = 4)\n",
    "\n",
    "grid.fit(X_train, y_train)\n",
    "\n",
    "print('SVC-最佳度量值:',grid.best_score_)  # 获取最佳度量值\n",
    "print('SVC-最佳参数：',grid.best_params_)  # 获取最佳度量值时的代定参数的值。是一个字典"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEWCAYAAACXGLsWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzs3Xl81NW9+P/XmSWZbGTfSAIJS1iSGJYQQFaBINqCpb+qUG21XLX1Vr3a9tZer1W0trW93qptvT601a63an+016KFYBIWASWBAErCmkCAhEwWsi+TzHK+f8wQkpCQhUxmPnCej0ceyXw+5zPznkA+7zm7kFKiKIqiKFej83QAiqIoivdTyUJRFEUZkEoWiqIoyoBUslAURVEGpJKFoiiKMiCVLBRFUZQBqWShKIqiDEglC0W5BkKIhUKIT4QQjUKIOiHEXiHEIiFEqxAisI/yh4QQj7h+9hFCbBRCnHKVLxNCvC2ESBzt96EoA1HJQlGGSQgxBvgQ+BUQBsQBzwGNQDnwlV7lU4HpwDuuQ5uANcBXgWAgHSgElo9C+IoyJELN4FaU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caaiFw4K/xhoNbN/jjpPNiRNvXC2o6QqgpMpcvLZ5WdDhSQ9C1xHcObNYeArZhbL/wVKagMqgJPhprdifGbXbwP/CkwFTgO7zWxdtKmunKTfBP4FSABPmtljEUfKmKSngTsJpsM+BjxqZj+ONFQGJK0GXgP2Evy9A/y9mb0YXarMSLoJ+HeC368S4Bkz+05OvpcXC+ecc+l4N5Rzzrm0vFg455xLy4uFc865tLxYOOecS8uLhXPOubS8WDh3FST1pd/rsq//L0kLw/s1kp6Q1C5ph6RfSVopqVzSVklFddGsy29eLJwbI5KWAgkz6wg3/YhgYr56M7sV+GOgNpx0sAF4KJqkzn2SFwvnMqDA4+EcVnslPRRuL5H0/XA9kU2SXpT0e+HLHgb+O9zvWmAl8A9mNgxgZofM7Jfhvs+H+zuXF/ww17nM/A6wDLiZ4IrmbZK2AquAOmAJMI1g+usnw9esAp4O7y8luBo9dYn3bwaW5yS5cxnwIwvnMrMaeDqc8fMY8CrBh/tq4OdmNmxm3cCWEa+ZCfRcyZuHRWQwXJzHuch5sXBu7AwAleH9FuDmcDW9S6kAzuU8lXNXwIuFc5l5DXgoXHhmKrAGaALeAH43HLuYTjDx3gWtwCIAM2sHtgPfDmdBRVKdpPvD+9cAJ8wsOVYNcu5yvFg4l5lfAHuAt4HNwDfCbqdnCVbE2wf8B7ATOBO+5pd8vHj8KTAdaJPUDPwbwWpnAHeF+zuXF3zWWedGmaQaM+sLjw6agFVm1h2uN7AlfHypge0L7/Ec8IiZHRiDyM6l5WdDOTf6/jdckKYc+G54xIGZDUh6lGAd7iOXenG4UNLzXihcPvEjC+ecc2n5mIVzzrm0vFg455xLy4uFc865tLxYOOecS8uLhXPOubT+H+kWK69rpgu7AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# plot CV误差曲线\n",
    "test_means = grid.cv_results_[ 'mean_test_score' ]\n",
    "test_scores =  np.array(test_means).reshape(len(Cs),len(kernels))\n",
    "\n",
    "x_axis = np.log10(Cs)\n",
    "for i, value in enumerate(kernels):\n",
    "    pyplot.plot(x_axis, test_scores[:,i], label= kernels[i])\n",
    "    \n",
    "pyplot.legend(loc='best')\n",
    "pyplot.xlabel( 'log(C)' )                                                                                                      \n",
    "pyplot.ylabel( 'accuary' )\n",
    "pyplot.title('SVC')\n",
    "\n",
    "pyplot.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SVC-最佳度量值: 0.7745740498034076\n",
      "SVC-最佳参数： {'C': 1}\n"
     ]
    }
   ],
   "source": [
    "#C在1附近最优，缩小搜索范围试试\n",
    "c1=10**(1.0/3)\n",
    "Cs = [0.1, 0.1*c1, 0.1*c1*c1, 1, c1, c1*c1, 10]\n",
    "\n",
    "grid = GridSearchCV(SVC(kernel='rbf',gamma='auto',decision_function_shape='ovo'), param_grid= {'C': Cs}, cv=5, n_jobs = 4)\n",
    "\n",
    "grid.fit(X_train, y_train)\n",
    "\n",
    "print('SVC-最佳度量值:',grid.best_score_)  \n",
    "print('SVC-最佳参数：',grid.best_params_)  # 获取最佳度量值时的代定参数的值。是一个字典"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "RBF核是SVM最常用的核函数。 RBF核SVM 的需要调整正则超参数包括C（正则系数，一般在log域（取log后的值）均匀设置候选参数）和核函数的宽度gamma，C越小，决策边界越平滑； gamma越小，决策边界越平滑。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SVC-最佳度量值: 0.7758846657929227\n",
      "SVC-最佳参数： {'gamma': 0.125}\n"
     ]
    }
   ],
   "source": [
    "gammas = [1.0/10,1.0/9,1.0/8,1.0/7,1.0/6,1.0/5,1.0/4, 1.0/3, 1.0/2,1]\n",
    "param_grid = {'gamma': gammas}\n",
    "grid = GridSearchCV(SVC(C=1,kernel='rbf',decision_function_shape='ovo'), param_grid, cv=5, n_jobs = 4)\n",
    "\n",
    "grid.fit(X_train, y_train)\n",
    "\n",
    "SVC_best_score=grid.best_score_ # 获取最佳度量值\n",
    "print('SVC-最佳度量值:',SVC_best_score)  \n",
    "print('SVC-最佳参数：',grid.best_params_)  # 获取最佳度量值时的代定参数的值。是一个字典"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEWCAYAAACXGLsWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3Xt8XHWd//HXO0mTNhd6SUILvYMN5X4LKKByEdwqCqIoxSuKgiKsP1bX5SFeKosPV3dddlFcxRVBXCksClu1CiiCCgVbtAht6YVyaQv0Si9JaNMkn98fc5JO0zRn2mZm0uT9fDzmwZwz58x8ckjm3fP9fs/3KCIwMzPrTUmxCzAzs/7PYWFmZqkcFmZmlsphYWZmqRwWZmaWymFhZmapHBZmZpbKYWG2DyS9UdKjkjZJ2iDpEUlvktQsqbqH7f8q6crkebmkGZKWJts/L+kWSZMK/XOYpXFYmO0lSQcAvwS+DYwCxgJfBTYBK4ELu21/FHAEcEey6m7gPOD9wHDgWOAJ4C0FKN9sj8hXcJvtHUmNwG8jYkQPr30BODsizspa901gSkRcIOls4BdAQ0SsKFjRZnvJZxZme28J0C7pNklvkzQy67XbgTdLGg8gqYTMGcRtyetnA392UNj+wmFhtpciYjPwRiCAHwBrJc2SNDoJgYeADyWbvwWoAH6VLNcCLxe2YrO957Aw2wcRsSgiLomIccBRwMHAfyQv38aOsPgQMDMitifL64GDClqs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ln39v2rPmLuraLiA5JndtcDawmc1ZTwsC+6ZPtB9wMZbZ7jwDvlDRUUjXwjmR9DfCypCHAB/L02cOBl5P7MnyIzER6ZkXjsDDbjYiYS6bf4W9k7lb4FLAJ+BLwOJkweSZPH/9d4COSngSmAs15+hyznHjWWbNeSKqOiKZkxNMfgMsi4i/Frsus0NxnYda7myUdQeamOrc5KGyw8pmFmZmlcp+FmZmlcliYmVkqh4WZmaVyWJiZWSqHhZmZpfr/VBjo659aL/4AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# plot CV误差曲线\n",
    "test_means = grid.cv_results_[ 'mean_test_score' ]\n",
    "test_stds = grid.cv_results_[ 'std_test_score' ]\n",
    "\n",
    "pyplot.errorbar(gammas, test_means, test_stds)\n",
    "    \n",
    "pyplot.xlabel( 'gamma' )                                                                                                      \n",
    "pyplot.ylabel( 'accuary' )\n",
    "pyplot.title('SVC')\n",
    "\n",
    "pyplot.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "每个类的支持向量的数目：\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([238, 238], dtype=int32)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print('每个类的支持向量的数目：')\n",
    "grid.best_estimator_.n_support_"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "4.标准化，但不做缺失值填补"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/chenxiangkong/.local/lib/python3.6/site-packages/sklearn/preprocessing/data.py:625: DataConversionWarning: Data with input dtype int64, float64 were all converted to float64 by StandardScaler.\n",
      "  return self.partial_fit(X, y)\n",
      "/home/chenxiangkong/.local/lib/python3.6/site-packages/sklearn/base.py:462: DataConversionWarning: Data with input dtype int64, float64 were all converted to float64 by StandardScaler.\n",
      "  return self.fit(X, **fit_params).transform(X)\n"
     ]
    }
   ],
   "source": [
    "#input data\n",
    "train = pd.read_csv(\"pima-indians-diabetes.csv\")\n",
    "\n",
    "#  get labels\n",
    "y_train = train['Target']   \n",
    "X_train = train.drop([\"Target\"], axis=1)\n",
    "\n",
    "# 数据标准化\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "\n",
    "# 初始化特征的标准化器\n",
    "ss_X = StandardScaler()\n",
    "\n",
    "# 分别对训练和测试数据的特征进行标准化处理\n",
    "X_train = ss_X.fit_transform(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "LinearSVC-最佳度量值: 0.7734375\n",
      "LinearSVC-最佳参数： {'C': 0.1, 'penalty': 'l2'}\n"
     ]
    }
   ],
   "source": [
    "#线性SVC\n",
    "from sklearn.svm import LinearSVC\n",
    "\n",
    "Cs = [0.001, 0.01, 0.1, 1, 10, 100, 1000]\n",
    "penaltys=['l1','l2']\n",
    "param_grid = {'C': Cs,'penalty': penaltys}\n",
    "grid = GridSearchCV(LinearSVC(dual=False), param_grid, cv=5, n_jobs = 4)\n",
    "\n",
    "grid.fit(X_train, y_train)\n",
    "\n",
    "src_LinearSVC_best_score=grid.best_score_  # 获取最佳度量值\n",
    "print('LinearSVC-最佳度量值:',src_LinearSVC_best_score)\n",
    "print('LinearSVC-最佳参数：',grid.best_params_)  # 获取最佳度量值时的代定参数的值。是一个字典"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SVC-最佳度量值: 0.7747395833333334\n",
      "SVC-最佳参数： {'C': 0.01, 'kernel': 'linear'}\n"
     ]
    }
   ],
   "source": [
    "#线性SVM\n",
    "from sklearn.svm import SVC\n",
    "\n",
    "Cs = [0.001, 0.01, 0.1, 1, 10, 100, 1000]\n",
    "kernels=['linear','poly','rbf','sigmoid']\n",
    "param_grid = {'C': Cs,'kernel': kernels}\n",
    "grid = GridSearchCV(SVC(gamma='auto',decision_function_shape='ovo'), param_grid, cv=5, n_jobs = 4)\n",
    "\n",
    "grid.fit(X_train, y_train)\n",
    "\n",
    "print('SVC-最佳度量值:',grid.best_score_)  # 获取最佳度量值\n",
    "print('SVC-最佳参数：',grid.best_params_)  # 获取最佳度量值时的代定参数的值。是一个字典"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SVC-最佳度量值: 0.7747395833333334\n",
      "SVC-最佳参数： {'C': 0.01}\n"
     ]
    }
   ],
   "source": [
    "#C在0.01附近最优，缩小搜索范围试试\n",
    "c1=10**(1.0/3)\n",
    "Cs = [0.001, 0.001*c1, 0.001*c1*c1, 0.01, 0.01*c1, 0.01*c1*c1, 0.1]\n",
    "\n",
    "grid = GridSearchCV(SVC(kernel='linear',decision_function_shape='ovo'), param_grid= {'C': Cs}, cv=5, n_jobs = 4)\n",
    "\n",
    "grid.fit(X_train, y_train)\n",
    "\n",
    "\n",
    "print('SVC-最佳度量值:',grid.best_score_)  \n",
    "print('SVC-最佳参数：',grid.best_params_)  # 获取最佳度量值时的代定参数的值。是一个字典"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "LinearSVC-缺省值处理-最佳度量值: 0.7693315858453473\n",
      "LinearSVC-未处理缺省-最佳度量值: 0.7734375\n",
      "SVC-缺省值处理-最佳度量值: 0.7758846657929227\n",
      "SVC-未处理缺省-最佳度量值: 0.7747395833333334\n"
     ]
    }
   ],
   "source": [
    "print('LinearSVC-缺省值处理-最佳度量值:',LinearSVC_best_score)\n",
    "print('LinearSVC-未处理缺省-最佳度量值:',src_LinearSVC_best_score)\n",
    "print('SVC-缺省值处理-最佳度量值:',SVC_best_score)\n",
    "print('SVC-未处理缺省-最佳度量值:',grid.best_score_) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "总结：\n",
    "1）线性SVM比带核SVM训练效率高很多，但拟合效果较差，原因是训练数据不是明显线性可分的，而通过核方法将特征扩展到高维后，能拟合非线性分类。\n",
    "2）处理缺省值比不填充缺省值的效果稍好，原因是处理缺省值减少了数据可能存在的噪声，而SVM对噪声很敏感。（个人认为采用PCA降维减少噪声等手段后，能进一步提升SVM效果）\n",
    "3）实验结果显示训练出来的n_support_大大少于样本数，说明SVM由于满足KKT对偶互补性，权重变稀疏了（大多数点可以抛掉， 不必保存）。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
